package mr.aurelien.blackboard.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;


public class Pen extends View {

	private int size=1;
	private Paint paint = new Paint();
	
	public Pen(Context context) {
		super(context);
		paint.setAntiAlias(true);
		paint.setStyle(Paint.Style.FILL);
		paint.setStrokeJoin(Paint.Join.ROUND);
		paint.setStrokeWidth(this.size);
	}
	
	public Pen(Context context, AttributeSet attrs) {
		super(context, attrs);
		paint.setAntiAlias(true);
		paint.setStyle(Paint.Style.FILL);
		paint.setStrokeJoin(Paint.Join.ROUND);
		paint.setStrokeWidth(this.size);
	}
	
	public Pen(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		paint.setAntiAlias(true);
		paint.setStyle(Paint.Style.FILL);
		paint.setStrokeJoin(Paint.Join.ROUND);
		paint.setStrokeWidth(this.size);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		int y = canvas.getHeight()/2;
		int x = canvas.getWidth()/2;
			
		canvas.drawCircle(x, y, size, paint);
	}
	
	public int SetSize(int size)
	{
		if(size>0)
		{
			this.size=size*3;
		}
		else
		{
			this.size=1;
		}
		invalidate();
		return this.size;
	}
	
	public void SetColor(int color)
	{
		paint.setColor(color);
		invalidate();
	}
}
